package com.cl.short_video_java.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @Author 付
 * @Date 2024-12-04 11:16
 * @Version 1.0
 * @description
 * @since 1.0
 */
@Configuration
@EnableAsync
public class ThreadPoolConfig {

	/**
	 * 线程池配置
	 * @return
	 */
	@Bean
	public Executor asyncExecutor() {
		ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
		executor.setCorePoolSize(8);
		executor.setMaxPoolSize(20);
		executor.setQueueCapacity(500);
		executor.setThreadNamePrefix("FileUpload-");
		executor.initialize();
		return executor;
	}
}